package circularcase;

import java.util.Scanner;

public class case1 {
    public static void main(String[] args) {
        System.out.println("--------循环--------");
        for (int time = 1; time <= 10; time++) {
            System.out.println("尝试得到一个回文数，第" + time + "次尝试");
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入一个整数：");
            String str = scanner.next();
            // 使用 StringBuilder 替代 String 进行字符串拼接，提高性能
            StringBuilder reversed = new StringBuilder();
            for (int i = str.length() - 1; i >= 0; i--) {
                reversed.append(str.charAt(i));
                System.out.println(str.charAt(i));
            }
            System.out.println(reversed.getClass());
            String reversedStr = reversed.toString();
            //查看reversedStr类型
            System.out.println(reversedStr.getClass());

            System.out.println(reversed);
            System.out.println(reversedStr);
            System.out.println(reversedStr.equals(str));

            // 判断是否为回文数
            if (str.equals(reversedStr)) {
                System.out.println("是回文数");
                // 关闭 Scanner 资源
                scanner.close();
                break;
            } else {
                System.out.println("不是回文数");
            }
        }

    }
}
